#include <stdio.h>
#include <stdint.h>
#include <audio_hpf.h>

#define kSampleRate8kHz 8000

static const int16_t kFilterCoefficients8kHz[5] =
{3798,-7596,3798,7807,-3733};

static const int16_t kFilterCoefficients[5] =
{3665,-7330,3665,7285,-3280};

int InitializeFilter(void *filter,int sample_rate_hz)
{
	FilterState* hpf = (FilterState*)filter;
	if(NULL == hpf){
		printf("hpf is NULL\n");
		return -1;
	}
	if(sample_rate_hz == kSampleRate8kHz) {
		hpf->ba = kFilterCoefficients8kHz;
	} else {
		hpf->ba = kFilterCoefficients;
	}
	audio_process_hpf_create(hpf->x,hpf->y,0,0,2,4);
	return 0;
}

int IngenicHPF_Filter(void * filter, short* data, int size)
{
	int ret = -1;
	char *p = (char*)data;
	int i = 0,k = 0,samples = 0;

	k = size/160;
	samples = size/2/k;  /*name is:80,samples number*/

	for (i = 0;i < k;i++){
		ret = audio_process_hpf_process(filter,(short*)(p+160*i),samples);
		if (ret != 0){
			printf("audio_process_hpf_process error\n");
			return -1;
		}
	}
	return 0;
}

